<%= render 'spree/admin/shared/shipping_tabs' %>

<% admin_breadcrumb(Spree.t(:stock_movements_for_stock_location, stock_location_name: @stock_location.name)) %>


<% content_for :page_actions do %>
  <% if can?(:create, Spree::StockMovement) %>
    <li>
      <%= button_link_to Spree.t(:new_stock_movement), new_admin_stock_location_stock_movement_path(@stock_location), id: 'admin_new_stock_movement_link' %>
    </li>
  <% end %>

  <% if can?(:display, Spree::StockLocation) %>
    <li>
      <%= link_to_with_icon 'arrow-left', Spree.t(:back_to_stock_locations_list), admin_stock_locations_path, :class => 'button' %>
    </li>
  <% end %>
<% end %>

<% if @stock_movements.any? %>
<table class="index" id='listing_stock_movements'>
  <colgroup>
    <col style="width: 35%">
    <col style="width: 20%">
    <col style="width: 45%">
  </colgroup>
  <thead>
    <tr data-hook="admin_stock_movements_index_headers">
      <th><%= Spree::StockMovement.human_attribute_name(:stock_item) %>
      <th><%= Spree::StockMovement.human_attribute_name(:quantity) %></th>
      <th><%= Spree::StockMovement.human_attribute_name(:action) %></th>
    </tr>
  </thead>
  <tbody>
    <% @stock_movements.each do |stock_movement|%>
      <tr id="<%= spree_dom_id stock_movement %>" data-hook="admin_stock_movements_index_rows" class="<%= cycle('odd', 'even')%>">
        <td class="align-center">
          <%= display_variant(stock_movement) %>
        </td>
        <td class="align-center"><%= stock_movement.quantity %></td>
        <td class="align-center"><%= pretty_originator(stock_movement) %></td>
      </tr>
    <% end %>
  </tbody>
</table>
<% else %>
  <div class="col-xs-9 no-objects-found">
    <%= render 'spree/admin/shared/no_objects_found',
                 resource: Spree::StockMovement,
                 new_resource_url: new_object_url %>
  </div>
<% end %>

<%= paginate @stock_movements, theme: "solidus_admin" %>
